<template>
	<view class="memberCard">
		<headertop str1="oridei" title="会员卡"></headertop>
		<view class="membertop">
			<image src="https://shop.hacuu.com/static/Rectangle 24369@2x.png" class="membertopimg" mode=""></image>
			<view class="membercd">
				<image src="https://shop.hacuu.com/static/Group 11608@2x (1).png" class="membercdback"
					mode="aspectFill"></image>
				<view class="userinfo" v-if="memberobj.user">
					<image :src="memberobj.user.avatar" class="leftimg" mode=""></image>
					<view class="texts">
						<view class="t1">
							{{memberobj.user.nickname}}
						</view>
						<view class="t2">
							会员有效期至：{{timestampfun(memberobj.user.levelend*1000)}}
						</view>
					</view>
				</view>
				<view class="memberline">
					<image src="https://shop.hacuu.com/static/Frame@2x (30).png" class="hg" mode=""></image>
					<image src="https://shop.hacuu.com/static/VIP会员@2x.png" class="vipicon" mode=""></image>

				</view>
			</view>
			<view class="bottomcontent">
				<image src="https://shop.hacuu.com/static/Subtract@2x.png" class="bottomcontentback" mode=""></image>
				<view class="widthscrrow">
					<view class="" style="width: 224rpx;overflow: hidden;display: inline-block;margin-right: 28rpx;"
						v-for="(item,index) in memberobj.vip" :key="item.id" @click="active=index">
						<view class="itembox">
							<view :class="active==index?'title ff':'title'">
								{{item.title}}
							</view>
							<view :class="active==index?'jiage ff':'jiage'">
								<span style="font-size: 24rpx;">￥</span>{{item.title}}
							</view>
							<view class="hxjiage">
								￥{{item.price}}
								<view class="hx">

								</view>
							</view>
							<view :class="active==index?'bottombox ff1':'bottombox'">
								享受{{item.zhekou}}折优惠
							</view>
						</view>
					</view>
				</view>
				<view class="memberbox1">
					<view class="titleline">
						<image src="https://shop.hacuu.com/static/Vector 481@2x.png" class="xt" mode=""></image>
						<span>会员专属权益</span>
						<image src="https://shop.hacuu.com/static/Vector 482@2x.png" class="xt" mode=""></image>
					</view>

					<view class="quanyibox" v-if="memberobj.vip">
						<up-parse
							:content="active==-1?memberobj.vip_detail:memberobj.vip[active]['content']"></up-parse>
					</view>


				</view>
			</view>
		</view>

		<view class="" style="height: 240rpx;">

		</view>
		<view class="fixed">
			<view class="btnkt">
				<view class="btnktback">
					￥<span
						style="font-size: 44rpx;font-weight: bold;color: #915E2C;">{{active==-1?0:memberobj.vip[active]['price']}}</span>/月
					<image src="https://shop.hacuu.com/static/Rectangle 23090@2x.png" class="btnktback1" mode="">
					</image>
				</view>
				<view class="ljkt" @click="ljkt">
					立即开通
				</view>
			</view>
			<view class="kttext" @click="flag=!flag">
				<image
					:src="flag?'https://shop.hacuu.com/static/Group 11469@2x (1).png':'https://shop.hacuu.com/static/Ellipse 2226@2x.png'"
					mode="" class="gxk"></image> 开通并同意
				<span style="color: #A46F3A;">《唇齿留香会员协议》</span>
			</view>
		</view>
	</view>
</template>

<script setup>
	import headertop from '@/components/header.vue'
	import {
		onPageScroll,
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	import {
		viplist
	} from '@/api/home.js'
	import {
		ref
	} from 'vue'
	const memberobj = ref({})
	const active = ref(-1)
	const flag = ref(false)
	onLoad(() => {
		init()
		console.log(123123);
	})
	async function init() {
		const res = await viplist()
		if (res.code == 1) {
			memberobj.value = res.data
			console.log(memberobj.value, 'memberobjmemberobjmemberobjmemberobj');
		}
	}

	function timestampfun(time) {
		const date = new Date(time);
		const year = date.getFullYear();
		const month = String(date.getMonth() + 1).padStart(2, "0");
		const day = String(date.getDate()).padStart(2, "0");
		const hours = String(date.getHours()).padStart(2, "0");
		const minutes = String(date.getMinutes()).padStart(2, "0");
		const seconds = String(date.getSeconds()).padStart(2, "0");
		const formattedDate = `${year}-${month}-${day}`;
		return formattedDate
	}

	function ljkt() {
		if (!flag.value) {
			uni.showToast({
				title: '请勾选会员协议',
				icon: 'none'
			})
			return
		}
	}
</script>
<style lang="scss">
	.msgicon {
		width: 608rpx;
		margin: auto;
		overflow: hidden;

		.msgtext {
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #86909C;
			text-align: center;
			width: 100%;
			margin-top: -30rpx;
		}

		image {
			width: 608rpx;
		}
	}

	.ff {
		color: #A46F3A !important;
	}

	.ff1 {
		background: #EDCC92 !important;
		color: #fff !important;
	}

	.memberCard {
		width: 100%;
		overflow: hidden;


		.fixed {
			width: 100%;
			height: 240rpx;
			background: #FFFFFF;
			box-shadow: 0rpx -4rpx 8rpx 0rpx rgba(0, 0, 0, 0.04);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			position: fixed;
			bottom: 0%;
			overflow: hidden;


			.kttext {
				width: 686rpx;
				margin-top: 12rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #86909C;
				display: flex;
				align-items: center;

				.gxk {
					width: 32rpx;
					height: 32rpx;
					margin-right: 20rpx;
				}
			}

			.btnkt {
				width: 686rpx;
				height: 92rpx;
				border-radius: 55rpx 55rpx 55rpx 55rpx;
				background: #3E3C46;
				display: flex;
				align-items: center;
				margin-top: 20rpx;

				.ljkt {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
				}

				.btnktback {
					width: 508rpx;
					height: 92rpx;
					position: relative;
					text-align: center;
					line-height: 92rpx;
					font-weight: 500;
					font-size: 24rpx;
					color: #A46F3A;
					z-index: 9999;

					.btnktback1 {
						width: 508rpx;
						height: 92rpx;
						position: absolute;
						z-index: -1;
						left: 0%;
					}
				}
			}
		}

		.membertop {
			width: 100%;
			overflow: hidden;
			position: relative;

			.bottomcontent {
				width: 100%;
				overflow: hidden;
				position: relative;
				margin-top: -40rpx;
			}

			.bottomcontentback {
				width: 100%;
				height: 1838rpx;
				position: absolute;
				z-index: -1;

			}

			.memberbox1 {
				width: 686rpx;
				margin: auto;
				overflow-y: scroll;
				margin-top: 30rpx;
				min-height: 500rpx;

				.quanyithree {
					width: 686rpx;
					background: linear-gradient(360deg, #FFFFFF 79%, #FFF5E5 100%);
					box-shadow: 0rpx -4rpx 8rpx 0rpx rgba(228, 193, 146, 0.38);
					border-radius: 12rpx 12rpx 12rpx 12rpx;
					overflow: hidden;
					margin-top: 30rpx;
					position: relative;
					margin-bottom: 60rpx;

					.huiyuanlips {
						width: 640rpx;
						margin: auto;
						margin-top: 30rpx;
						overflow: hidden;

						.itemhuiyuanlp {
							width: 640rpx;
							height: 184rpx;
							background: #F7F8FA;
							border-radius: 12rpx 12rpx 12rpx 12rpx;
							display: flex;
							align-items: center;
							margin-bottom: 30rpx;

							image {
								width: 172rpx;
								height: 152rpx;
								margin-left: 10rpx;
							}

							.texts {
								margin-left: 30rpx;

								.t1 {
									width: 338rpx;
									font-family: PingFang SC, PingFang SC;
									font-weight: 500;
									font-size: 28rpx;
									color: #1D2129;
								}

								.t2 {
									font-family: PingFang SC, PingFang SC;
									font-weight: bold;
									font-size: 28rpx;
									color: #A46F3A;
									margin-top: 30rpx;
								}
							}
						}
					}

					.titlelinemember {
						width: 100%;
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 30rpx;
						color: #A46F3A;
						margin-top: 50rpx;
					}

					.quanyibs {
						width: 84rpx;
						height: 36rpx;
						background: #A46F3A;
						border-radius: 10rpx 0rpx 10rpx 0rpx;
						text-align: center;
						line-height: 36rpx;
						font-size: 24rpx;
						color: #FFFFFF;
						position: absolute;
						left: 0%;
						top: 0%;
					}
				}

				.quanyibox {
					width: 100%;
					display: flex;
					align-items: center;
					margin-top: 30rpx;
					justify-content: space-between;

					.itemquanyi {
						width: 328rpx;
						height: 142rpx;
						background: rgba(255, 255, 255, 0.52);
						box-shadow: 0rpx 4rpx 8rpx 0rpx #E4C192;
						border-radius: 12rpx 12rpx 12rpx 12rpx;
						border: 2rpx solid #FFFFFF;
						position: relative;

						.quanyibs {
							width: 84rpx;
							height: 36rpx;
							background: #A46F3A;
							border-radius: 10rpx 0rpx 10rpx 0rpx;
							text-align: center;
							line-height: 36rpx;
							font-size: 24rpx;
							color: #FFFFFF;
							position: absolute;
							left: 0%;
							top: 0%;
						}

						.zszktitle {
							font-weight: bold;
							font-size: 30rpx;
							color: #A46F3A;
							margin-top: 50rpx;
							margin-left: 16rpx;
						}

						.text {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 20rpx;
							color: #D5A87A;
							margin-left: 16rpx;
							margin-top: 16rpx;
						}
					}
				}

				.titleline {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 30rpx;
					color: #A46F3A;

					.xt {
						width: 250rpx;
						height: 12rpx;
					}
				}

			}

			.widthscrrow {
				width: 718rpx;
				margin-left: 32rpx;
				white-space: nowrap;
				overflow-x: scroll;
				margin-top: 78rpx;

				.itembox {
					width: 224rpx;
					height: 240rpx;
					background: #FFFFFF;
					border-radius: 16rpx 16rpx 16rpx 16rpx;
					border: 2rpx solid #D1986F;
					display: flex;
					flex-direction: column;
					align-items: center;
					overflow: hidden;
					position: relative;
					box-sizing: border-box;

					.bottombox {
						width: 220rpx;
						height: 54rpx;
						text-align: center;
						line-height: 54rpx;
						background: #FFEAC9;
						border-radius: 0rpx 0rpx 14rpx 14rpx;
						font-weight: bold;
						font-size: 24rpx;
						position: absolute;
						bottom: 0%;
						color: #4E5969;
					}

					.hxjiage {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 20rpx;
						color: #949494;
						position: relative;
						margin-top: 14rpx;

						.hx {
							width: 100%;
							height: 1rpx;
							background: #949494;
							position: absolute;
							top: 60%;
						}
					}

					.jiage {
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 40rpx;
						color: #4E5969;
						margin-top: 20rpx;
					}

					.title {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #4E5969;
						margin-top: 30rpx;
					}
				}

			}

			.membertopimg {
				width: 100%;
				height: 900rpx;
				position: absolute;
				z-index: -1;
			}

			.membercd {
				width: 689rpx;
				margin: auto;
				overflow: hidden;
				position: relative;
				margin-top: 150rpx;


				.membercdback {

					width: 100%;
					position: absolute;
					z-index: -1;
				}

				.memberline {
					width: 600rpx;
					margin: auto;
					margin-top: 60rpx;
					margin-bottom: 30rpx;

					.hg {
						width: 44rpx;
						height: 44rpx;
					}

					.vipicon {
						width: 164rpx;
						height: 40rpx;
					}
				}

				.userinfo {
					width: 600rpx;
					margin: auto;
					margin-top: 130rpx;
					display: flex;
					align-items: center;

					.leftimg {
						width: 82rpx;
						height: 82rpx;
						border-radius: 50%;
					}

					.texts {
						margin-left: 16rpx;

						.t1 {
							font-family: PingFang SC, PingFang SC;
							font-weight: bold;
							font-size: 32rpx;
							color: #A46F3A;
						}

						.t2 {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 20rpx;
							color: #A46F3A;
							margin-top: 12rpx;
						}
					}
				}
			}
		}
	}
</style>